/**
 * <copyright>
 *
 * Copyright (c) 2011 Zeligsoft (2009) Limited
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: 
 *   Zeligsoft (2009) Limited - Initial API and implementation
 *
 * </copyright>
 *
 */
package org.omg.deployment.parts.forms;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent;
import org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart;
import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart;
import org.eclipse.emf.eef.runtime.ui.parts.PartComposer;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.BindingCompositionSequence;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.CompositionSequence;
import org.eclipse.emf.eef.runtime.ui.utils.EditingUtils;
import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableContentProvider;
import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.omg.deployment.ExternalReferenceEndpoint;
import org.omg.deployment.PlanSubcomponentPortEndpoint;
import org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart;
import org.omg.deployment.parts.DeploymentViewsRepository;
import org.omg.deployment.providers.DeploymentMessages;

import com.google.common.base.Joiner;


/**
 * @author Toby McClean; Zeligsoft (2009) Limited
 * @generated
 */
public class ConnectionEndsPropertiesEditionPartForm extends CompositePropertiesEditionPart implements IFormPropertiesEditionPart, ConnectionEndsPropertiesEditionPart {

		protected TableViewer ends;
		protected List<ViewerFilter> endsBusinessFilters = new ArrayList<ViewerFilter>();
		protected List<ViewerFilter> endsFilters = new ArrayList<ViewerFilter>();



	protected TableViewer externalEndPoint;
    protected List<ViewerFilter> externalEndPointBusinessFilters = new ArrayList<ViewerFilter>();
    protected List<ViewerFilter> externalEndPointFilters = new ArrayList<ViewerFilter>();
    protected TableViewer externalReference;
    protected List<ViewerFilter> externalReferenceBusinessFilters = new ArrayList<ViewerFilter>();
    protected List<ViewerFilter> externalReferenceFilters = new ArrayList<ViewerFilter>();



  /**
	 * Default constructor
	 * @param editionComponent the {@link IPropertiesEditionComponent} that manage this part
	 * @generated
	 */
	public ConnectionEndsPropertiesEditionPartForm(IPropertiesEditionComponent editionComponent) {
    super(editionComponent);
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart#
	 *  createFigure(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit)
	 * @generated
	 */
	public Composite createFigure(final Composite parent, final FormToolkit widgetFactory) {
    ScrolledForm scrolledForm = widgetFactory.createScrolledForm(parent);
    Form form = scrolledForm.getForm();
    view = form.getBody();
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    view.setLayout(layout);
    createControls(widgetFactory, view);
    return scrolledForm;
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart#
	 *  createControls(org.eclipse.ui.forms.widgets.FormToolkit, org.eclipse.swt.widgets.Composite)
	 * @generated
	 */
	public void createControls(final FormToolkit widgetFactory, Composite view) {
    CompositionSequence connectionEndsStep = new BindingCompositionSequence(propertiesEditionComponent);
    connectionEndsStep
      .addStep(DeploymentViewsRepository.ConnectionEnds.InternalEndPoint.class)
      .addStep(DeploymentViewsRepository.ConnectionEnds.InternalEndPoint.ends);
    
    connectionEndsStep
      .addStep(DeploymentViewsRepository.ConnectionEnds.ExternalEndPoint.class)
      .addStep(DeploymentViewsRepository.ConnectionEnds.ExternalEndPoint.externalEndPoint_);
    
    connectionEndsStep
      .addStep(DeploymentViewsRepository.ConnectionEnds.ExternalReference.class)
      .addStep(DeploymentViewsRepository.ConnectionEnds.ExternalReference.externalReference_);
    
    
    composer = new PartComposer(connectionEndsStep) {

      @Override
      public Composite addToPart(Composite parent, Object key) {
        if (key == DeploymentViewsRepository.ConnectionEnds.InternalEndPoint.class) {
          return createInternalEndPointGroup(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.ConnectionEnds.InternalEndPoint.ends) {
          return createEndsTableComposition(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.ConnectionEnds.ExternalEndPoint.class) {
          return createExternalEndPointGroup(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.ConnectionEnds.ExternalEndPoint.externalEndPoint_) {
          return createExternalEndPointTableComposition(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.ConnectionEnds.ExternalReference.class) {
          return createExternalReferenceGroup(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.ConnectionEnds.ExternalReference.externalReference_) {
          return createExternalReferenceTableComposition(widgetFactory, parent);
        }
        return parent;
      }
    };
    composer.compose(view);
  }
	/**
   * @generated
   */
  protected Composite createInternalEndPointGroup(FormToolkit widgetFactory, final Composite parent) {
    Section internalEndPointSection = widgetFactory.createSection(parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    internalEndPointSection.setText(DeploymentMessages.ConnectionEndsPropertiesEditionPart_InternalEndPointGroupLabel);
    GridData internalEndPointSectionData = new GridData(GridData.FILL_HORIZONTAL);
    internalEndPointSectionData.horizontalSpan = 3;
    internalEndPointSection.setLayoutData(internalEndPointSectionData);
    Composite internalEndPointGroup = widgetFactory.createComposite(internalEndPointSection);
    GridLayout internalEndPointGroupLayout = new GridLayout();
    internalEndPointGroupLayout.numColumns = 3;
    internalEndPointGroup.setLayout(internalEndPointGroupLayout);
    internalEndPointSection.setClient(internalEndPointGroup);
    return internalEndPointGroup;
  }

  /**
	 * @param container
	 * @generated NOT
	 */
	protected Composite createEndsTableComposition(FormToolkit widgetFactory, Composite container) {
    Composite tableContainer = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout tableContainerLayout = new GridLayout();
    GridData tableContainerData = new GridData(GridData.FILL_BOTH);
    tableContainerData.horizontalSpan = 3;
    tableContainer.setLayoutData(tableContainerData);
    tableContainerLayout.numColumns = 2;
    tableContainer.setLayout(tableContainerLayout);
    org.eclipse.swt.widgets.Table tableEnds = widgetFactory.createTable(tableContainer, SWT.FULL_SELECTION | SWT.BORDER);
    tableEnds.setHeaderVisible(true);
    tableEnds.setEnabled(true);
    tableEnds.setToolTipText(DeploymentMessages.ConnectionEnds_ReadOnly);
    GridData gdEnds = new GridData();
    gdEnds.grabExcessHorizontalSpace = true;
    gdEnds.horizontalAlignment = GridData.FILL;
    gdEnds.grabExcessVerticalSpace = true;
    gdEnds.verticalAlignment = GridData.FILL;
    tableEnds.setLayoutData(gdEnds);
    tableEnds.setLinesVisible(true);

    TableColumn name = new TableColumn(tableEnds, SWT.READ_ONLY);
	name.setWidth(100);
	name.setText("Instance"); //$NON-NLS-1$
	
	TableColumn port = new TableColumn(tableEnds, SWT.READ_ONLY);
	port.setWidth(100);
	port.setText("Port"); //$NON-NLS-1$
	
	TableColumn kind = new TableColumn(tableEnds, SWT.READ_ONLY);
	kind.setWidth(100);
	kind.setText("Kind");
	
	TableColumn provider = new TableColumn(tableEnds, SWT.READ_ONLY);
	provider.setWidth(50);
	provider.setText("Provider");
    

    ends = new TableViewer(tableEnds);
    ends.setContentProvider(new ArrayContentProvider());
    ends.setLabelProvider(new ITableLabelProvider() {
            public String getColumnText(Object object, int columnIndex) {
              if (object instanceof EObject) {
            	  PlanSubcomponentPortEndpoint end = (PlanSubcomponentPortEndpoint) object;
            	  switch (columnIndex) {
	                case 0:
						if(end.getInstanceRef() != null) {
							return end.getInstanceRef().getName().trim();
						} else if(end.getInstance() != null) {
							return end.getInstance().getIdref().trim();
						}
					case 1:
						return end.getPortName().trim();
					case 2:
						return end.getKind().getName().trim();
					case 3:
						return end.getProvider();
                }
              }
              return ""; //$NON-NLS-1$
            }
      
            public Image getColumnImage(Object element, int columnIndex) {
              return null;
            }
      

      public void addListener(ILabelProviderListener listener) {
      }

      public void dispose() {
      }

      public boolean isLabelProperty(Object element, String property) {
        return false;
      }

      public void removeListener(ILabelProviderListener listener) {
      }

    });
    ends.getTable().addListener(SWT.MouseDoubleClick, new Listener(){

      public void handleEvent(Event event) {
        if (ends.getSelection() instanceof IStructuredSelection) {
          IStructuredSelection selection = (IStructuredSelection) ends.getSelection();
          if (selection.getFirstElement() instanceof EObject) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ConnectionEndsPropertiesEditionPartForm.this, DeploymentViewsRepository.ConnectionEnds.InternalEndPoint.ends, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
            ends.refresh();
          }
        }
      }

    });
    GridData endsData = new GridData(GridData.FILL_HORIZONTAL);
    endsData.minimumHeight = 80;
    endsData.heightHint = 80;
    ends.getTable().setLayoutData(endsData);
    for (ViewerFilter filter : this.endsFilters) {
      ends.addFilter(filter);
    }
    EditingUtils.setID(ends.getTable(), DeploymentViewsRepository.ConnectionEnds.InternalEndPoint.ends);
    EditingUtils.setEEFtype(ends.getTable(), "eef::TableComposition::field"); //$NON-NLS-1$
    createEndsPanel(widgetFactory, tableContainer);
    return container;
  }

	/**
	 * @param container
	 * @generated NOT
	 */
	protected Composite createEndsPanel(FormToolkit widgetFactory, Composite container) {
    Composite endsPanel = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout endsPanelLayout = new GridLayout();
    endsPanelLayout.numColumns = 1;
    endsPanel.setLayout(endsPanelLayout);
    
    return endsPanel;
  }



	/**
   * @generated
   */
  protected Composite createExternalEndPointGroup(FormToolkit widgetFactory, final Composite parent) {
    Section externalEndPointSection = widgetFactory.createSection(parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    externalEndPointSection.setText(DeploymentMessages.ConnectionEndsPropertiesEditionPart_ExternalEndPointGroupLabel);
    GridData externalEndPointSectionData = new GridData(GridData.FILL_HORIZONTAL);
    externalEndPointSectionData.horizontalSpan = 3;
    externalEndPointSection.setLayoutData(externalEndPointSectionData);
    Composite externalEndPointGroup = widgetFactory.createComposite(externalEndPointSection);
    GridLayout externalEndPointGroupLayout = new GridLayout();
    externalEndPointGroupLayout.numColumns = 3;
    externalEndPointGroup.setLayout(externalEndPointGroupLayout);
    externalEndPointSection.setClient(externalEndPointGroup);
    return externalEndPointGroup;
  }

  /**
   * @param container
   * @generated NOT
   */
  protected Composite createExternalEndPointTableComposition(FormToolkit widgetFactory, Composite container) {
    Composite tableContainer = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout tableContainerLayout = new GridLayout();
    GridData tableContainerData = new GridData(GridData.FILL_BOTH);
    tableContainerData.horizontalSpan = 3;
    tableContainer.setLayoutData(tableContainerData);
    tableContainerLayout.numColumns = 2;
    tableContainer.setLayout(tableContainerLayout);
    org.eclipse.swt.widgets.Table tableExternalEndPoint = widgetFactory.createTable(tableContainer, SWT.FULL_SELECTION | SWT.BORDER);
    tableExternalEndPoint.setHeaderVisible(true);
    tableExternalEndPoint.setEnabled(true);
    tableExternalEndPoint.setToolTipText(DeploymentMessages.ConnectionEnds_ReadOnly);
    GridData gdExternalEndPoint = new GridData();
    gdExternalEndPoint.grabExcessHorizontalSpace = true;
    gdExternalEndPoint.horizontalAlignment = GridData.FILL;
    gdExternalEndPoint.grabExcessVerticalSpace = true;
    gdExternalEndPoint.verticalAlignment = GridData.FILL;
    tableExternalEndPoint.setLayoutData(gdExternalEndPoint);
    tableExternalEndPoint.setLinesVisible(true);

        TableColumn name = new TableColumn(tableExternalEndPoint, SWT.NONE);
        name.setWidth(100);
        name.setText("Port Name"); //$NON-NLS-1$
    

    externalEndPoint = new TableViewer(tableExternalEndPoint);
    externalEndPoint.setContentProvider(new ArrayContentProvider());
    externalEndPoint.setLabelProvider(new ITableLabelProvider() {
            public String getColumnText(Object object, int columnIndex) {
              AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
              if (object instanceof EObject) {
                switch (columnIndex) {
                case 0:
                  return labelProvider.getText(object);
                }
              }
              return ""; //$NON-NLS-1$
            }
      
            public Image getColumnImage(Object element, int columnIndex) {
              return null;
            }
      

      public void addListener(ILabelProviderListener listener) {
      }

      public void dispose() {
      }

      public boolean isLabelProperty(Object element, String property) {
        return false;
      }

      public void removeListener(ILabelProviderListener listener) {
      }

    });
    externalEndPoint.getTable().addListener(SWT.MouseDoubleClick, new Listener(){

      public void handleEvent(Event event) {
        if (externalEndPoint.getSelection() instanceof IStructuredSelection) {
          IStructuredSelection selection = (IStructuredSelection) externalEndPoint.getSelection();
          if (selection.getFirstElement() instanceof EObject) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ConnectionEndsPropertiesEditionPartForm.this, DeploymentViewsRepository.ConnectionEnds.ExternalEndPoint.externalEndPoint_, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
            externalEndPoint.refresh();
          }
        }
      }

    });
    GridData externalEndPointData = new GridData(GridData.FILL_HORIZONTAL);
    externalEndPointData.minimumHeight = 120;
    externalEndPointData.heightHint = 120;
    externalEndPoint.getTable().setLayoutData(externalEndPointData);
    for (ViewerFilter filter : this.externalEndPointFilters) {
      externalEndPoint.addFilter(filter);
    }
    EditingUtils.setID(externalEndPoint.getTable(), DeploymentViewsRepository.ConnectionEnds.ExternalEndPoint.externalEndPoint_);
    EditingUtils.setEEFtype(externalEndPoint.getTable(), "eef::TableComposition::field"); //$NON-NLS-1$
    createExternalEndPointPanel(widgetFactory, tableContainer);
    return container;
  }

  /**
   * @param container
   * @generated NOT
   */
  protected Composite createExternalEndPointPanel(FormToolkit widgetFactory, Composite container) {
    Composite externalEndPointPanel = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout externalEndPointPanelLayout = new GridLayout();
    externalEndPointPanelLayout.numColumns = 1;
    externalEndPointPanel.setLayout(externalEndPointPanelLayout);
    return externalEndPointPanel;
  }

  /**
   * @generated
   */
  protected Composite createExternalReferenceGroup(FormToolkit widgetFactory, final Composite parent) {
    Section externalReferenceSection = widgetFactory.createSection(parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    externalReferenceSection.setText(DeploymentMessages.ConnectionEndsPropertiesEditionPart_ExternalReferenceGroupLabel);
    GridData externalReferenceSectionData = new GridData(GridData.FILL_HORIZONTAL);
    externalReferenceSectionData.horizontalSpan = 3;
    externalReferenceSection.setLayoutData(externalReferenceSectionData);
    Composite externalReferenceGroup = widgetFactory.createComposite(externalReferenceSection);
    GridLayout externalReferenceGroupLayout = new GridLayout();
    externalReferenceGroupLayout.numColumns = 3;
    externalReferenceGroup.setLayout(externalReferenceGroupLayout);
    externalReferenceSection.setClient(externalReferenceGroup);
    return externalReferenceGroup;
  }

  /**
   * @param container
   * @generated NOT
   */
  protected Composite createExternalReferenceTableComposition(FormToolkit widgetFactory, Composite container) {
    Composite tableContainer = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout tableContainerLayout = new GridLayout();
    GridData tableContainerData = new GridData(GridData.FILL_BOTH);
    tableContainerData.horizontalSpan = 3;
    tableContainer.setLayoutData(tableContainerData);
    tableContainerLayout.numColumns = 2;
    tableContainer.setLayout(tableContainerLayout);
    org.eclipse.swt.widgets.Table tableExternalReference = widgetFactory.createTable(tableContainer, SWT.FULL_SELECTION | SWT.BORDER);
    tableExternalReference.setHeaderVisible(true);
    tableExternalReference.setEnabled(true);
    tableExternalReference.setToolTipText(DeploymentMessages.ConnectionEnds_ReadOnly);
    GridData gdExternalReference = new GridData();
    gdExternalReference.grabExcessHorizontalSpace = true;
    gdExternalReference.horizontalAlignment = GridData.FILL;
    gdExternalReference.grabExcessVerticalSpace = true;
    gdExternalReference.verticalAlignment = GridData.FILL;
    tableExternalReference.setLayoutData(gdExternalReference);
    tableExternalReference.setLinesVisible(true);

        TableColumn provider = new TableColumn(tableExternalReference, SWT.NONE);
        provider.setWidth(100);
        provider.setText("Provider"); //$NON-NLS-1$
        
        TableColumn portName = new TableColumn(tableExternalReference, SWT.NONE);
        portName.setWidth(100);
        portName.setText("Port"); //$NON-NLS-1$
        
        TableColumn location = new TableColumn(tableExternalReference, SWT.NONE);
        location.setWidth(100);
        location.setText("Location"); //$NON-NLS-1$
        
        TableColumn supportedType = new TableColumn(tableExternalReference, SWT.NONE);
        supportedType.setWidth(100);
        supportedType.setText("SupportedType"); //$NON-NLS-1$
    

    externalReference = new TableViewer(tableExternalReference);
    externalReference.setContentProvider(new ArrayContentProvider());
    externalReference.setLabelProvider(new ITableLabelProvider() {
            public String getColumnText(Object object, int columnIndex) {
              if (object instanceof ExternalReferenceEndpoint) {
            	  ExternalReferenceEndpoint externalReference = (ExternalReferenceEndpoint) object;
                switch (columnIndex) {
                case 0:
                  return externalReference.getProvider();
                case 1:
                	return externalReference.getPortName();
                case 2:
                	return externalReference.getLocation();
                case 3:
                	return Joiner.on(", ").skipNulls().join(externalReference.getSupportedType());
                }
              }
              return ""; //$NON-NLS-1$
            }
      
            public Image getColumnImage(Object element, int columnIndex) {
              return null;
            }
      

      public void addListener(ILabelProviderListener listener) {
      }

      public void dispose() {
      }

      public boolean isLabelProperty(Object element, String property) {
        return false;
      }

      public void removeListener(ILabelProviderListener listener) {
      }

    });
    externalReference.getTable().addListener(SWT.MouseDoubleClick, new Listener(){

      public void handleEvent(Event event) {
        if (externalReference.getSelection() instanceof IStructuredSelection) {
          IStructuredSelection selection = (IStructuredSelection) externalReference.getSelection();
          if (selection.getFirstElement() instanceof EObject) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ConnectionEndsPropertiesEditionPartForm.this, DeploymentViewsRepository.ConnectionEnds.ExternalReference.externalReference_, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
            externalReference.refresh();
          }
        }
      }

    });
    GridData externalReferenceData = new GridData(GridData.FILL_HORIZONTAL);
    externalReferenceData.minimumHeight = 120;
    externalReferenceData.heightHint = 120;
    externalReference.getTable().setLayoutData(externalReferenceData);
    for (ViewerFilter filter : this.externalReferenceFilters) {
      externalReference.addFilter(filter);
    }
    EditingUtils.setID(externalReference.getTable(), DeploymentViewsRepository.ConnectionEnds.ExternalReference.externalReference_);
    EditingUtils.setEEFtype(externalReference.getTable(), "eef::TableComposition::field"); //$NON-NLS-1$
    createExternalReferencePanel(widgetFactory, tableContainer);
    return container;
  }

  /**
   * @param container
   * @generated NOT
   */
  protected Composite createExternalReferencePanel(FormToolkit widgetFactory, Composite container) {
    Composite externalReferencePanel = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout externalReferencePanelLayout = new GridLayout();
    externalReferencePanelLayout.numColumns = 1;
    externalReferencePanel.setLayout(externalReferencePanelLayout);
    return externalReferencePanel;
  }

  /**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionListener#firePropertiesChanged(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
	 * @generated
	 */
	public void firePropertiesChanged(IPropertiesEditionEvent event) {
  }



	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#initEnds(EObject current, EReference containingFeature, EReference feature)
	 */
	public void initEnds(ReferencesTableSettings settings) {
		if (current.eResource() != null && current.eResource().getResourceSet() != null)
			this.resourceSet = current.eResource().getResourceSet();
		ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider();
		ends.setContentProvider(contentProvider);
		ends.setInput(settings);
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#updateEnds()
	 * @generated
	 */
	public void updateEnds() {
  ends.refresh();
}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#addFilterEnds(ViewerFilter filter)
	 * @generated
	 */
	public void addFilterToEnds(ViewerFilter filter) {
    endsFilters.add(filter);
    if (this.ends != null) {
      this.ends.addFilter(filter);
    }
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#addBusinessFilterEnds(ViewerFilter filter)
	 * @generated
	 */
	public void addBusinessFilterToEnds(ViewerFilter filter) {
    endsBusinessFilters.add(filter);
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#isContainedInEndsTable(EObject element)
	 * @generated
	 */
	public boolean isContainedInEndsTable(EObject element) {
    return ((ReferencesTableSettings)ends.getInput()).contains(element);
  }




	/**
   * {@inheritDoc}
   * 
   * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#initExternalEndPoint(EObject current, EReference containingFeature, EReference feature)
   */
  public void initExternalEndPoint(ReferencesTableSettings settings) {
    if (current.eResource() != null && current.eResource().getResourceSet() != null)
      this.resourceSet = current.eResource().getResourceSet();
    ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider();
    externalEndPoint.setContentProvider(contentProvider);
    externalEndPoint.setInput(settings);
  }

  /**
   * {@inheritDoc}
   * 
   * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#updateExternalEndPoint()
   * @generated
   */
  public void updateExternalEndPoint() {
  externalEndPoint.refresh();
}

  /**
   * {@inheritDoc}
   * 
   * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#addFilterExternalEndPoint(ViewerFilter filter)
   * @generated
   */
  public void addFilterToExternalEndPoint(ViewerFilter filter) {
    externalEndPointFilters.add(filter);
    if (this.externalEndPoint != null) {
      this.externalEndPoint.addFilter(filter);
    }
  }

  /**
   * {@inheritDoc}
   * 
   * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#addBusinessFilterExternalEndPoint(ViewerFilter filter)
   * @generated
   */
  public void addBusinessFilterToExternalEndPoint(ViewerFilter filter) {
    externalEndPointBusinessFilters.add(filter);
  }

  /**
   * {@inheritDoc}
   * 
   * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#isContainedInExternalEndPointTable(EObject element)
   * @generated
   */
  public boolean isContainedInExternalEndPointTable(EObject element) {
    return ((ReferencesTableSettings)externalEndPoint.getInput()).contains(element);
  }

  /**
   * {@inheritDoc}
   * 
   * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#initExternalReference(EObject current, EReference containingFeature, EReference feature)
   */
  public void initExternalReference(ReferencesTableSettings settings) {
    if (current.eResource() != null && current.eResource().getResourceSet() != null)
      this.resourceSet = current.eResource().getResourceSet();
    ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider();
    externalReference.setContentProvider(contentProvider);
    externalReference.setInput(settings);
  }

  /**
   * {@inheritDoc}
   * 
   * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#updateExternalReference()
   * @generated
   */
  public void updateExternalReference() {
  externalReference.refresh();
}

  /**
   * {@inheritDoc}
   * 
   * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#addFilterExternalReference(ViewerFilter filter)
   * @generated
   */
  public void addFilterToExternalReference(ViewerFilter filter) {
    externalReferenceFilters.add(filter);
    if (this.externalReference != null) {
      this.externalReference.addFilter(filter);
    }
  }

  /**
   * {@inheritDoc}
   * 
   * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#addBusinessFilterExternalReference(ViewerFilter filter)
   * @generated
   */
  public void addBusinessFilterToExternalReference(ViewerFilter filter) {
    externalReferenceBusinessFilters.add(filter);
  }

  /**
   * {@inheritDoc}
   * 
   * @see org.omg.deployment.parts.ConnectionEndsPropertiesEditionPart#isContainedInExternalReferenceTable(EObject element)
   * @generated
   */
  public boolean isContainedInExternalReferenceTable(EObject element) {
    return ((ReferencesTableSettings)externalReference.getInput()).contains(element);
  }

  /**
	 * {@inheritDoc}
	 *
	 * @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle()
	 * @generated
	 */
	public String getTitle() {
    return DeploymentMessages.ConnectionEnds_Part_Title;
  }



}
